package xiaohuo.fancyring.util

import org.bukkit.inventory.ItemStack
import taboolib.platform.util.hasLore
import taboolib.platform.util.modifyLore
import xiaohuo.fancyring.config.ConfigManager
import xiaohuo.fancyring.data.RealBodyData
import xiaohuo.fancyring.data.RingData

fun ItemStack.getRing(): List<RingData> {
    val rings = arrayListOf<RingData>()
    modifyLore {
        forEach { lore ->
            rings += ConfigManager.ringMap.values.filter { it.lore in lore }
        }
    }
    return rings
}

fun ItemStack.getRealBody(): RealBodyData? {
    return ConfigManager.realBodyList.firstOrNull { hasLore(it.match) }
}